轻量级站点统计代码
感谢番茄提供的代码。
<li id="text-5" class="widget widget_text"><h2 class="widgettitle">站点统计</h2> <div class="textwidget"></div> <div class="widget"> <ul> <li>建站时间:2012年06月09日</li> <li>网站运行:<?php echo floor((time()-strtotime("2012-06-09"))/86400); ?>天</li> <li>文章总数:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?></li> <li>分类总数:<?php echo $count_categories = wp_count_terms('category'); ?>个</li> <li>评论总数:<?php echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments");?></li> <li>最后更新:<?php $last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')");$last = date('Y-n-j', strtotime($last[0]->MAX_m));echo $last; ?></li> </ul> </div> </li>
这个统计准不准啊?
估计精度不高!!!
精度?难道你要算到毫秒级?
这个不错